package com.rookie.rookiemeeting.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.rookie.rookiemeeting.common.lang.Result;
import com.rookie.rookiemeeting.entity.Mypass;
import com.rookie.rookiemeeting.service.IMypassService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author henry-ong
 * @since 2023-12-23
 */
@RestController
@RequestMapping("/mypass")
@Api(tags = "仿真测试模块")
public class MypassController {
    IMypassService mypassService;

    @Autowired
    public MypassController(IMypassService mypassService) {
        this.mypassService = mypassService;
    }

    @ApiOperation("提交测试结果")
    @PostMapping("/save")
    public Result save(@RequestBody Mypass mypass) {
        return Result.succ(mypassService.addTestInfo(mypass));
    }

    @ApiOperation("查询可用的测试结果")
    @PostMapping("/list")
    public Result list() {
        return Result.succ(mypassService.queryAll());
    }

    @ApiOperation("根据已登录的员工ID查询自己的会议并且会议状态为0接口")
    @GetMapping("/mytests")
    public Result mytests(@RequestParam Integer pageNum,
                          @RequestParam Integer pageSize,
                          @RequestParam(defaultValue = "") String employeename) {
        String query ="%" + employeename.trim() + "%";
        return Result.succ(mypassService.queryTestInfoByEmployee(new Page<>(pageNum, pageSize), query));
    }
}
